﻿using System;
using System.Linq.Expressions;
using System.Reflection;

namespace Basmus.Util
{
    public static class PropertySelector
    {
        public static PropertyInfo GetPropertyInfo<T, TProperty>(this Expression<Func<T, TProperty>> propertySelector)
        {
            var member = propertySelector.Body as MemberExpression;
            if (member != null)
            {
                var property = member.Member as PropertyInfo;
                if (property != null)
                {
                    return property;
                }
            }
            return null;
        }
    }
}
